package com.example.account.DataBase;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

@Database(entities = {TypeData.class}, version = 3, exportSchema = false)
public abstract class TypeDatabase extends RoomDatabase {
    private static TypeDatabase INSTANCE;

    static public TypeDatabase getDatabase(Context context) {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder(context, TypeDatabase.class, "type_database")
                    .allowMainThreadQueries()
                    .fallbackToDestructiveMigration() // 放在 build() 之前
                    .build();
        }
        return INSTANCE;
    }

    public abstract TypeDataDao getDataDao();
}
